package dict

import (
	"context"
	"net/http"
	"ruoyi_zero/domain/system"
	"ruoyi_zero/internal/svc"
	"ruoyi_zero/internal/types"
	"ruoyi_zero/utils"

	"github.com/zeromicro/go-zero/core/logx"
)

type DictListLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewDictListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DictListLogic {
	return &DictListLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *DictListLogic) DictList(req *types.DictListRequest) (resp *types.AjaxResult, err error) {
	// todo: add your logic here and delete this line

	var param = utils.SearchTableDataParam{
		PageNum:  req.PageNum,
		PageSize: req.PageSize,
		//Other: system.SysDept{DeptName: req.DeptName,
		//	Status: req.Status,
		//},
		//Params: utils.Params{
		//	BeginTime: req.Params.BeginTime,
		//	EndTime:   req.Params.EndTime,
		//},
	}

	var rows, total = system.GetDeptList(param, false)
	if total > 0 {
		for _, dept := range rows {
			dept.Children = []system.SysDeptResult{}
		}
	}

	resp = new(types.AjaxResult)

	resp.Data = rows
	resp.Code = http.StatusOK
	resp.Msg = "操作成功"
	return
}
